<?php

/**
 * +------ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER * ---------+
 * +----------------------------------------------------------------------------+
 * | PHPKiisf - Keep It in Simple Framework					|
 * | Version 1.0								|
 * | Copyright (C) <2013>  Mario Cezzare <mcezzare@gmail.com>			|
 * | Blog: http://mcezzare.blogspot.com.br					|
 * |										|
 * | This program is part of PHPKiisf, and is free software: you can		|
 * | redistribute it and/or modify it under the terms of the GNU 		|
 * | General Public License as published by					|
 * | the Free Software Foundation, either version 3 of the License, or		|
 * | (at your option) any later version.					|					|
 * |										|									|
 * | This program is distributed in the hope that it will be useful,		|
 * | but WITHOUT ANY WARRANTY; without even the implied warranty of		|
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the		|
 * | GNU General Public License for more details.				|
 * | You should have received a copy of the GNU General Public License		|
 * | along with this program.  If not, see <http://www.gnu.org/licenses/>.	|
 * +----------------------------------------------------------------------------+
 * | Author : <Mario Cezzare Angelicola Chiodi> <mcezzare@gmail.com>		|
 * +----------------------------------------------------------------------------+
 * | Contributors								|
 * |										|
 * +----------------------------------------------------------------------------+
 *
 */

/**
 * Base class for other templates
 *
 * @package	Templates
 * @access	public
 * @since	2013-03-08
 * @author	Mario Cezzare <mcezzare@gmail.com>
 */
class base_template {

	public static $skin = "default" ;
	public static $public_dir ; //for php files
	public static $public_media_dir ; //for html,js,css,php
	public static $target_file ; //the final .inc.php that will be called.
	public static $name_file = "index" ;
	public static $section_name ;

	/**
	 * $skin_files array Used to store the default name files.
	 * Maybe it's safer to use protected to develop future skins
	 */
	public static $skin_files ;

	/**
	 * $global_params  array  This must used to store the information
	 * coming from dispatcher and then on the extended default controller
	 * on include the desired template method "include_template" on second param $params
	 * this must be usaed as an array
	 */
	public static $global_params = array() ;
	private $can_run = false ;

	public function __construct() {
		//@todo , decide if it stays
		// spl_autoload_register( 'base_template::init' ) ;
	}

	/**
	 *
	 */
	public static function init() {
		self::$public_dir = sprintf( "%sskins/%s" , TEMPLATES_DIR , self::$skin ) ;
		self::$public_media_dir = sprintf( "//%sskins/%s" , $_SERVER["HTTP_HOST"] . substr( TEMPLATES_DIR , 1 , strlen( TEMPLATES_DIR ) ) , self::$skin ) ;
//need fix after first slash on url
		self::$target_file = sprintf( "skins/%s/%s%s" , self::$skin , self::$name_file , INCLUDE_EXTENSION ) ;

		self::$skin_files = array(
			/* the default skin files must be named like this */
			"index" => array(
				"filename" => self::$public_dir . "/index" . INCLUDE_EXTENSION ,
				"required" => true ,
			) ,
			"header" => array(
				"filename" => self::$public_dir . "/header" . INCLUDE_EXTENSION ,
				"required" => true ,
			) ,
			"navbar" => array(
				"filename" => self::$public_dir . "/navbar" . INCLUDE_EXTENSION ,
				"required" => false ,
			) ,
			"container" => array(
				"filename" => self::$public_dir . "/container" . INCLUDE_EXTENSION ,
				"required" => true ,
			) ,
			"footer" => array(
				"filename" => self::$public_dir . "/footer" . INCLUDE_EXTENSION ,
				"required" => true ,
			) ,
			) ;
		return ;
	}

	/**
	 *
	 * @return type
	 */
	public static function load() {

		if ( utils::check_template( TEMPLATES_DIR . self::$target_file ) ) {
			require self::$target_file ;
			return ;
		}
	}

	public static function display_index( $param0 = null ) {

	}

}

spl_autoload_register( 'base_template::init' ) ;
?>